<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function Game(uname, type, blood) {
            this.name = uname;
            this.type = type;
            this.blood = blood;
            this.attack = function(distance) {
                console.log(distance);
            }
        }
        var lianpo = new Game('廉颇', '力量型', '500血量');
        console.log(lianpo.name);
        console.log(lianpo.type);
        console.log(lianpo['blood']);
        lianpo.attack('近战');
        var houyi = new Game('后羿', '射手型', '100血量');
        console.log(houyi.name);
        console.log(houyi.type);
        console.log(houyi['blood']);
        lianpo.attack('远战');
    </script>
</body>

</html>